#ifndef FIFO_H
#define FIOF_H

#include "../msg.h"
#include "../Carama/carama.h"
#define FIFO_FORMAT YUYV_FORMAT
struct kfifo
{
    unsigned int fifo_size;         // 缓冲区的总大小
    unsigned int fifo_num;          // 总共分配了几个缓存
    unsigned int sigle_size;        // 每一小块的最大写入size
    unsigned int write_index;       // 写入到第几个了
    pthread_mutex_t lock;           // 一把大锁保平安
    pthread_cond_t not_empty;       // 用来通知读线程数据已到
    int read_count;                 // 用来标记是否有人在读
    void * buffer;                  // 真正的缓冲区
    void * msg_buffer;              // 缓冲信息的

};
struct kfifo * kfifo_alloc(unsigned int width,unsigned int height,unsigned int num);
int kfifo_write(struct kfifo *fifo, void *buffer, struct carama_msg *send_msg);
int kfifo_read(struct kfifo *fifo, void *buffer, unsigned int size, 
                struct carama_msg *recv_msg,unsigned int *read_index);
void kfifo_free(struct kfifo *fifo);
#endif